﻿<UserControl 
    x:Class="Google_Plus.Types.PostView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Google_Plus.Types"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:imageTools="clr-namespace:ImageTools.Controls;assembly=ImageTools.Controls" 
    xmlns:c4f="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid Background="{StaticResource PhoneBackgroundBrush}">
        <StackPanel Margin="5,15,5,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <HyperlinkButton VerticalAlignment="Top"
                                 HorizontalAlignment="Left" 
                                 NavigateUri="{Binding StringFormat=//Pages/ProfilePage.xaml?uid\=\{0\}, Path=AuthorID}">
                    <HyperlinkButton.Template>
                        <ControlTemplate>
                            <Image Width="64" Height="64"
                                   Source="{Binding AuthorPhoto}"/>
                        </ControlTemplate>
                    </HyperlinkButton.Template>
                </HyperlinkButton>
                <StackPanel Margin="0,-6,0,0" Grid.Column="1">
                    <HyperlinkButton HorizontalContentAlignment="Left"
                                     HorizontalAlignment="Left"
                                     NavigateUri="{Binding StringFormat=//Pages/ProfilePage.xaml?uid\=\{0\}, Path=AuthorID}">
                        <HyperlinkButton.Template>
                            <ControlTemplate>
                                <TextBlock Text="{Binding Author}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="#FFA2A2FF" />
                            </ControlTemplate>
                        </HyperlinkButton.Template>
                        <toolkit:ContextMenuService.ContextMenu>
                            <toolkit:ContextMenu>
                                <toolkit:MenuItem Header="View profile" FontWeight="Bold" x:Name="menuViewProfile" Click="menuViewProfile_Click"/>
                                <toolkit:Separator Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=CanMention}"/>
                                <toolkit:MenuItem Header="Mention" 
                                                  x:Name="menuMention" 
                                                  Click="menuMention_Click"
                                                  Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=CanMention}"/>
                            </toolkit:ContextMenu>
                        </toolkit:ContextMenuService.ContextMenu>
                    </HyperlinkButton>
                    <TextBlock Text="{Binding Information}"/>
                    <c4f:ChatBubble Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=HasContent}"
                                    ChatBubbleDirection="UpperLeft"
                                    HorizontalAlignment="Left">
                        <local:RichTextHelper FontSize="{StaticResource PhoneFontSizeMedium}"
                                              TextWrapping="Wrap"
                                              RichText="{Binding Content}" 
                                              ScrollViewer.VerticalScrollBarVisibility="Disabled" />
                    </c4f:ChatBubble>
                </StackPanel>
            </Grid>
            <Grid Margin="20 5 0 0" Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=IsReshare}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="55" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <HyperlinkButton VerticalAlignment="Top"
                                 HorizontalAlignment="Left" 
                                 NavigateUri="{Binding StringFormat=//Pages/ProfilePage.xaml?uid\=\{0\}, Path=OriginalAuthorID}">
                    <HyperlinkButton.Template>
                        <ControlTemplate>
                            <Image Width="48" Height="48"
                                           Source="{Binding OriginalAuthorPhoto}"/>
                        </ControlTemplate>
                    </HyperlinkButton.Template>
                </HyperlinkButton>
                <StackPanel Margin="0,-7,0,0" Grid.Column="1">
                    <toolkit:WrapPanel>
                        <TextBlock Text="Originally shared by " Margin="0 2 0 0"/>
                        <HyperlinkButton HorizontalContentAlignment="Left"
                                                 NavigateUri="{Binding StringFormat=//Pages/ProfilePage.xaml?uid\=\{0\}, Path=OriginalAuthorID}">
                            <HyperlinkButton.Template>
                                <ControlTemplate>
                                    <TextBlock Text="{Binding OriginalAuthor}"
                                               TextWrapping="Wrap"
                                               FontSize="{StaticResource PhoneFontSizeMedium}"
                                               Foreground="#FFA2A2FF" />
                                </ControlTemplate>
                            </HyperlinkButton.Template>
                        </HyperlinkButton>
                    </toolkit:WrapPanel>
                    <c4f:ChatBubble Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=HasOriginalContent}"
                                    ChatBubbleDirection="UpperLeft"
                                    HorizontalAlignment="Left">
                        <local:RichTextHelper FontSize="{StaticResource PhoneFontSizeMedium}"
                                              TextWrapping="Wrap"
                                              RichText="{Binding OriginalContent}" 
                                              ScrollViewer.VerticalScrollBarVisibility="Disabled"/>
                    </c4f:ChatBubble>
                </StackPanel>
            </Grid>
            <toolkit:WrapPanel Margin="20 5 0 0" Visibility="{Binding Path=Tag, Converter={StaticResource BoolToVisibilityConverter}}">
                <TextBlock Text="Shared from the Google+ " />
                <HyperlinkButton >
                    <HyperlinkButton.Template>
                        <ControlTemplate>
                            <TextBlock Text="{Binding Tag}" Foreground="#FFA2A2FF" />
                        </ControlTemplate>
                    </HyperlinkButton.Template>
                </HyperlinkButton>
                <TextBlock Text=" stream"/>
            </toolkit:WrapPanel>
            <StackPanel Margin="0,5,0,0">
                <Grid Visibility="{Binding Path=Media.HasLineOne, Converter={StaticResource BoolToVisibilityConverter}}">
                    <Image HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           MaxWidth="24" 
                           MaxHeight="24" 
                           Source="{Binding Media.Icon}"/>
                    <HyperlinkButton Margin="26,-5,0,0" 
                                     NavigateUri="{Binding Media.LinkLocation}"
                                     HorizontalContentAlignment="Left">
                        <HyperlinkButton.Template>
                            <ControlTemplate>
                                <TextBlock TextWrapping="Wrap"
                                           Text="{Binding StringFormat='\{0\} »', Path=Media.LineOne}"
                                           FontWeight="Bold"
                                           FontSize="{StaticResource PhoneFontSizeMedium}"
                                           Foreground="#FFA2A2FF" />
                            </ControlTemplate>
                        </HyperlinkButton.Template>
                    </HyperlinkButton>
                </Grid>
                <TextBlock TextWrapping="Wrap" 
                           Text="{Binding Media.LineTwo}" 
                           FontSize="{StaticResource PhoneFontSizeMedium}"/>
            </StackPanel>
            <local:LightBox DataContext="{Binding Media.Images}" MaxHeight="450" />
            <Grid>
                <StackPanel Orientation="Horizontal" Margin="10,0,90,0">
                    <Button Name="btnPlusOne" 
                        Content="{Binding StringFormat=+\{0\}, Path=PlusOneCount}"
                        BorderThickness="0" 
                        FontSize="{StaticResource PhoneFontSizeMedium}" 
                        Padding="10,0"
                        Foreground="{Binding PlusOneButtonBrush}"
                        Click="btnPlusOne_Click"
                        Tap="Button_Tap" />
                    <Button Name="btnReshare" 
                        BorderThickness="0"
                        Padding="10,0" 
                        Click="btnReshare_Click"
                        Tap="Button_Tap">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="48" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Image Height="48" Width="48" Source="/Images/appbar.social.retweet.rest.png"/>
                            <TextBlock Text="{Binding ReshareCount}"
                                       FontSize="{StaticResource PhoneFontSizeMedium}" 
                                       Margin="0,8,0,0"
                                       Grid.Column="1" />
                        </Grid>
                    </Button>
                    <Image Height="48" Width="48" Source="/Images/appbar.addcomment.rest.png"/>
                    <TextBlock Text="{Binding CommentCount}" 
                               FontSize="{StaticResource PhoneFontSizeMedium}"
                               Margin="0,20"
                               FontFamily="Segoe WP Semibold" />
                </StackPanel>
                <Button HorizontalAlignment="Right"
                        BorderThickness="0" 
                        Padding="0" 
                        Name="btnMenuSwitcher" 
                        Click="btnMenuSwitcher_Click"
                        Tap="Button_Tap">
                    <Image Height="48" 
                           Width="64" 
                           Stretch="UniformToFill" 
                           Source="/Images/appbar.overflowdots.png"/>
                </Button>
            </Grid>
            <Grid Height="5">
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu Name="cmPostMenu">
                        <toolkit:MenuItem Header="Edit post"/>
                        <toolkit:MenuItem Header="Disable comment"/>
                        <toolkit:MenuItem Header="Lock post"/>
                        <toolkit:MenuItem Header="Mute this post"/>
                        <toolkit:Separator/>
                        <toolkit:MenuItem Header="Delete post"/>
                        <toolkit:MenuItem Header="Report abuse"/>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
            </Grid>
            <StackPanel Margin="20,0,0,0">
                <ItemsControl ItemsSource="{Binding Replies}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <local:CommentView/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
